<template>
  <div class="boxs">
    <div style="margin:0 0 20px 0">会员卡号：{{customernumber.customerCard}}</div>
    <el-button style="margin:0 0 10px 95%" type="primary" size="mini" @click="returntop">返回</el-button>

    <!-- 底部表格 -->
    <div class="box-button-form">
      <el-table :header-cell-style="{
          color: '#fff',
          background: '#6090EC',
          fontSize: '11px',
          fontWeight: 'normal',}" :data="ordersList" border size="mini">
        <el-table-column prop="orderId" label="订单号" width="155">
        </el-table-column>
        <el-table-column prop="guestNum" label="订单票量" width="80">
        </el-table-column>
        <el-table-column label="乘机人" width="110">
          <template slot-scope="scope">
            <div v-for="(item, index) in scope.row.orderTickets" :key="index">
              {{ item.guestName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="pnr" label="PNR/记录编码" width="120">
        </el-table-column>
        <el-table-column label="PNR(机票)状态" width="120">
          <template slot-scope="scope">
            <div v-for="(item, index) in scope.row.orderTickets" :key="index">
              {{ item.actionCode }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="航程" width="80">
          <template slot-scope="scope">
            <div v-if="
                scope.row.orderTickets.length > 1 &&
                scope.row.orderTickets[1].tripType == 'rt'
              ">
              <div v-for="(item, index) in scope.row.orderTickets" :key="index">
                {{ item.tripType == "rt" ? "返程" : "去程" }}
              </div>
            </div>
            <div v-if="
                scope.row.orderTickets.length > 1 &&
                scope.row.orderTickets[1].tripType == 'ot'
              ">
              <div v-for="(item, index) in scope.row.orderTickets" :key="index">
                {{ item.tripType == "ot" ? "中转第二程" : "中转第一程" }}
              </div>
            </div>
            <div v-if="scope.row.orderTickets.length == 1">
              <div v-for="(item, index) in scope.row.orderTickets" :key="index">
                {{ item.tripType == "ow" ? "单程" : "" }}
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="航班号" width="80">
          <template slot-scope="scope">
            <div v-for="(item, index) in scope.row.orderTickets" :key="index">
              {{ item.flight }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="起飞时间">
          <template slot-scope="scope">
            <div v-for="(item, index) in scope.row.orderTickets" :key="index">
              {{ item.departureTime }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="预定时间" width="140">
        </el-table-column>
        <el-table-column prop="guestPymtStsId" label="支付状态" width="110">
          <template slot-scope="scope">
            <template v-if="scope.row.guestPymtStsId == 'payd'">已支付</template>
            <template v-if="scope.row.guestPymtStsId == 'waitPay'">等待支付</template>
            <template v-if="scope.row.guestPymtStsId == 'cancelled'">已取消</template>
            <template v-if="scope.row.guestPymtStsId == 'failPay'">支付失败</template>

            <template v-if="scope.row.guestPymtStsId=='refundTicketStatus_success'">退票成功</template>
            <template v-if="scope.row.guestPymtStsId=='rescheduled'">改期中</template>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="订单状态" width="110">
          <template slot-scope="scope">
            <template v-if="scope.row.status == 'waitPay'">等待支付</template>
            <template v-if="scope.row.status == 'cancelled'">已取消</template>
            <template v-if="scope.row.status == 'refundProgress'">退票中</template>
            <template v-if="scope.row.status == 'noTravel'">未出行</template>
            <template v-if="scope.row.status == 'rescheduled '">改期中</template>
            <template v-if="scope.row.status == 'changeTicketSucces'">改期成功</template>
            <template v-if="scope.row.status=='changeTicketSuccess'">退票成功</template>
            <template v-if="scope.row.status=='changeTicketFail'">退票失败</template>
            <template v-if="scope.row.status=='refundTicketStatus_success'">退票完成</template>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        ordersList: [],
        customernumber: {},
        customerId: "",
        currentPage: '',
        pageSize: ''
      };
    },
    methods: {
      // 返回
      returntop() {
        this.$router.go(-1)
      },
      // 会员卡号
      getinformation() {
        this.$axios.getinformation({
          id: this.customerId,
          // id:'77'
        }).then((res) => {
          console.log(res)
          this.customernumber = res.data
          if (res.code == 200) {
            this.getflightOrderInfoListCRM()
          }
        })
      },
      // 订单列表
      getflightOrderInfoListCRM() {
        localStorage.setItem("pageNum", this.currentPage);
        localStorage.setItem("pageSize", this.pageSize);
        this.$axios
          .getflightOrderInfoListCRM({
            orderId: '',
            arrivalTime: '',
            arrivalTimeEnd: '',
            gustName: '',
            gustPhone: this.customernumber.customerPhone,
            pnr: '',
          })
          .then((res) => {
            console.log(res);
            if (res.code == "200") {
              if (res.data == "") {
                this.$message({
                  message: "暂未查到数据",
                });
              } else {
                let arr = JSON.parse(JSON.stringify(res.data));
                arr.forEach((item) => {
                  item.orderTickets.forEach((items) => {
                    (items.actionCode = item.actionCode),
                    (items.createTime = item.createTime);
                    (items.orderId = item.orderId),
                    (items.guestNum = item.guestNum),
                    (items.pnr = item.pnr);
                  });
                });
                this.ordersList = arr;
              }
            } else {
              this.$confirm("请核对搜索条件是否有误", "提示", {
                confirmButtonText: "确定",
                type: "warning",
              });
            }
          });
      },

    },
    mounted() {
      this.customerId = this.$route.params.customerId;
      this.getinformation()
    },
  };
</script>

<style scoped>
  .boxs {
    margin: 20px;
  }
</style>